--TAO BANG THANHVIEN
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE NAME='THANHVIEN')
BEGIN
	DROP TABLE THANHVIEN
END
CREATE TABLE THANHVIEN
(
	TEN_DN		VARCHAR(20),
	MAT_KHAU	VARCHAR(20),
	MASV		VARCHAR(10),
	CONSTRAINT PK_TV PRIMARY KEY (TEN_DN)
)
GO
--TAO BANG DANGKY
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE NAME='DANGKY')
BEGIN
	DROP TABLE DANGKY
END 
CREATE TABLE DANGKY
(
	MASV		VARCHAR(10),
	MAMH		VARCHAR(10),
	CONSTRAINT PK_DK PRIMARY KEY (MASV,MAMH)
)
GO
--TAO BANG SINHVIEN
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE NAME='SINHVIEN')
BEGIN
	DROP TABLE SINHVIEN
END 
CREATE TABLE SINHVIEN
(
	MASV		VARCHAR(10),
	TEN_SV		NVARCHAR(50),
	NGAY_SINH	DATETIME,
	GIOI_TINH	VARCHAR(5),
	DIA_CHI		NVARCHAR(50),
	CONSTRAINT PK_SV PRIMARY KEY (MASV)
)
GO
--TAO BANG MONHOC
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE NAME='MONHOC')
BEGIN
	DROP TABLE MONHOC
END 
CREATE TABLE MONHOC
(
	MAMH		VARCHAR(10),
	TEN_MH		NVARCHAR(50),
	THOI_GIAN_BAT_DAU   DATETIME,
	THOI_GIAN_KET_THUC	DATETIME,
	CHUNG_CHI	INT,
	LE_PHI		INT,
	CONSTRAINT PK_MH PRIMARY KEY (MAMH)
)